package com.onejson.ojmall.controller;


import com.onejson.ojmall.common.domain.PageResult;
import com.onejson.ojmall.common.apiencrypt.domain.ValidateList;
import com.onejson.ojmall.common.domain.ResponseDTO;
import com.onejson.ojmall.model.form.SRoleDataScopeBatchForm;
import com.onejson.ojmall.model.form.SRoleDataScopeForm;
import com.onejson.ojmall.model.form.SRoleDataScopeQueryForm;
import com.onejson.ojmall.model.vo.SRoleDataScopeVO;
import com.onejson.ojmall.service.SRoleDataScopeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;


/**
 * 角色的数据范围控制器
 *
 * @author wxx
 */
@Slf4j
@RestController
@Tag(name = "角色的数据范围")
public class SRoleDataScopeController {


    //【角色的数据范围】Service层

    @Resource
    private SRoleDataScopeService sRoleDataScopeService;


    @Operation(summary = "【角色的数据范围】 - 查询")
    @PostMapping("/zichan/sRoleDataScope/queryPage")
    public ResponseDTO<PageResult<SRoleDataScopeVO>> querySRoleDataScope(@RequestBody @Valid SRoleDataScopeQueryForm queryForm) {
        return ResponseDTO.ok(sRoleDataScopeService.getList(queryForm));
    }

    @Operation(summary = " 【角色的数据范围】 - 详情")
    @GetMapping("/zichan/sRoleDataScope//{detailId}")
    public ResponseDTO<SRoleDataScopeVO> getInfo(@PathVariable("detailId") String detailId) {
        return ResponseDTO.ok(sRoleDataScopeService.queryById(detailId));
    }

    @Operation(summary = " 【角色的数据范围】 - 添加")
    @PostMapping("/zichan/sRoleDataScope/add")
    public ResponseDTO<String> addSRoleDataScope(@RequestBody @Valid SRoleDataScopeForm addForm) {
        return sRoleDataScopeService.addSRoleDataScope(addForm);
    }

    @Operation(summary = "【角色的数据范围】 - 更新")
    @PostMapping("/zichan/sRoleDataScope/update")
    public ResponseDTO<String> updateSRoleDataScope(@RequestBody @Valid SRoleDataScopeForm updateForm) {
        return sRoleDataScopeService.updateSRoleDataScope(updateForm);
    }

    @Operation(summary = "【角色的数据范围】 - 批量更新")
    @PostMapping("/zichan/sRoleDataScope/batchUpdate")
    public ResponseDTO<String> batchUpdateSRoleDataScope(@RequestBody @Valid SRoleDataScopeBatchForm sRoleDataScopeBatchForm) {
        return sRoleDataScopeService.batchUpdateSRoleDataScope(sRoleDataScopeBatchForm);
    }

    @Operation(summary = "【角色的数据范围】 - 批量删除")
    @PostMapping("/zichan/sRoleDataScope/batchDelete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<String> idList) {
        return sRoleDataScopeService.batchDelete(idList);
    }

    @Operation(summary = "【角色的数据范围】 - 单个删除")
    @GetMapping("/zichan/SRoleDataScope/delete/{id}")
    public ResponseDTO<String> batchDelete(@PathVariable String id) {
        return sRoleDataScopeService.delete(id);
    }

}

